﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using PatientInformationExtract.Dictionary.Models;

namespace PatientInformationExtract.Dictionary.Views
{
    /// <summary>
    /// Interaction logic for AddDictionaryCatalog.xaml
    /// </summary>
    public partial class AddDictionaryCatalog : Window
    {
        public delegate void AddDictionaryCatalogHandler(DictionaryCatalog catalog);

        public event AddDictionaryCatalogHandler AddDictionaryCatalogEvent;

        public AddDictionaryCatalog()
        {
            InitializeComponent();
            txtName.Focus();
        }

        public AddDictionaryCatalog(string catalogName)
            :this()
        {
            txtName.Text = catalogName;
            this.Title = "Rename Catalog";
            txtName.SelectAll();
        }

        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text != "")
            {
                DictionaryCatalog catalog = new DictionaryCatalog(txtName.Text);
                if (AddDictionaryCatalogEvent != null)
                {
                    AddDictionaryCatalogEvent(catalog);
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show(String.Format(DictionaryErrorMessages.ContentEmpty, "Catalog name"));
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
